﻿using FineAdmin.Common;
using FineAdmin.IService;
using FineAdmin.Model;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace HuiJi.CMS.Blog.Controllers
{
    public class MainController : BaseController
    {
        public IBlogPostsService BlogPostsService { get; set; }
        // GET: Main
        public ActionResult Index(int? PId, int? CId, int p = 1, int l = 10)
        {
            if (!PId.HasValue)
            {
                PId = 1;
            }
            ViewBag.PId = PId;
            ViewBag.CId = CId;
            BlogPostsModel model = new BlogPostsModel();
            model.PCId = PId;
            model.CId = CId;
            PageInfo pageInfo = new PageInfo();
            pageInfo.page = p;
            pageInfo.limit = l;

            int total;
            ViewBag.BlogPostsList = BlogPostsService.GetListByFilter(model, pageInfo, out total);
            ViewBag.Total = total;
            ViewBag.Page = p;
            return View();
        }

        public ActionResult About() {
            ViewBag.Active = "About";
            return View();
        }
    }
}